package com.srzk.youthleagueback.mapper;

import com.srzk.youthleagueback.pojo.Note;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface NoteMapper {

    @Insert("insert into note (user, year, content)" +
            "values (#{note.user}, #{note.year}, " +
            "#{note.content})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(@Param("note")Note record);

    @Select("SELECT * FROM note WHERE user = #{user} AND year = #{year}")
    Note selectByPrimaryKey(@Param("user") String user, @Param("year") String year);

    List<Note> selectAll();

    @Update("UPDATE note SET content = #{note.content} WHERE user = #{note.user} AND year = #{note.year}")
    int updateByPrimaryKey(@Param("note") Note record);
}